package com.xs.controller;

import com.xs.common.R;
import com.xs.domain.Collect;
import com.xs.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 徐双
 * @ClassName CollectController
 * @date 2023-03-03 14:14
 * @Description:
 * @Version:1.0
 */
@RestController
@RequestMapping("/collect")
public class CollectController {
    @Autowired
    private CollectService collectService;

    /**
     * 新增收藏
     * @param collect
     * @return
     */
    @PostMapping("/addCollect")
    public R addCollect(@RequestBody Collect collect){
        return collectService.insertCollect(collect);
    }

    /**
     * 删除收藏
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public R deleteCollect(@RequestParam Integer id) {
        return collectService.deleteCollect(id);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping("/delBatch")
    public R deleteBathIds(@RequestBody List<Integer> ids){
        System.out.println("test");
        return collectService.deleteBathIds(ids);
    }

    /**
     * 查询所有收藏
     * @return
     */
    @GetMapping("/allComment")
    public R allCollect() {
        return collectService.allCollect();
    }

    /**
     * 查询某个用户的收藏列表
     * @param consumerId
     * @return
     */
    @GetMapping("/collectOfConsumerId")
    public R collectOfConsumerId(@RequestParam Integer consumerId) {
        return collectService.collectOfConsumerId(consumerId);
    }

    /**
     * 判断用户是否收藏该乐谱
     * @param consumerId
     * @return
     */
    @GetMapping("/isCollectOfStaff")
    public R isCollectOfStaff(@RequestParam Integer consumerId,@RequestParam Integer staffId) {
        return collectService.isCollectOfStaff(consumerId,staffId);
    }

}
